// RESIZE TOP IMG

$(window).on('resize', function(){
   var navBg = $('.navBgh');
   var h = $(window).height() - $('.top').height();
   
   navBg.height(h);
   
   if($(window).width() < 640){
        if($('#filters').height() == 60){
            $('#filters').height(76);
        }
    } else {
        if($('#filters').height() == 76){
            $('#filters').height(60);
        }
    }   
});

var filterState = 'closed';

$('.openFilters').on('click', function(e){
    

    if(filterState == 'closed'){
        if($(window).width() < 640){
            $('#filters').animate({height: 76}, 200);
        } else {
            $('#filters').animate({height: 60}, 200);
        }
        
        $(this).css('border-color', '#DDD');
        $(this).children('i').attr('class', 'icon-remove');
        
        $('#filters').addClass('visible');
        
        $('#fBotLine').show();
        filterState = 'open';
    } else {
        $('#filters').animate({height: 0}, 200);
        
        $(this).css('border-color', '#FFF');
        $(this).children('i').attr('class', 'icon-caret-down');
        
        $('#filters').removeClass('visible');
        
        $('#fBotLine').hide();
        filterState = 'closed';
    }
});

var prodsState = 'closed';

$('.openProds').on('click', function(e){
    if($(window).width() < 640){
        if(prodsState == 'closed'){
            var rh = $('.products > .row').height();
            var h = rh*2 + 61;

            $('.products').animate({height: h}, 400)
            .delay(400)
            .queue( function(next){ 
              $('.products').css('height','auto'); 
              next();
            });
            
            prodsState = 'open';
        } else {
            $('.products').animate({height: 61}, 400);
            
            prodsState = 'closed';
        }
    }
});
